Compute valid CVSS scores from vectors in GitLab importer (#2330) - #2430
Open
hardikkaurani wants to merge 2 commits into
Open
Compute valid CVSS scores from vectors in GitLab importer (#2330)#2430hardikkaurani wants to merge 2 commits into
hardikkaurani wants to merge 2 commits into
Conversation
Resolves aboutcode-org#2330: - Use Cvssv2ScoringSystem and Cvssv3ScoringSystem to compute numeric base scores from GitLab cvss_v2 and cvss_v3 vectors - Support CVSS 3.0 and CVSS 3.1 scoring systems - Handle malformed vectors gracefully via CVSS2MalformedError and CVSS3MalformedError without interrupting importer execution - Add regression tests verifying score computation and malformed vector handling Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
hardikkaurani
force-pushed
the
fix/gitlab-cvss-score-2330
branch
from
September 13, 2026 20:19
2c0b5eb to
ed78fbc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GitLab advisories provide CVSS vectors in
cvss_v2andcvss_v3fields, butvulnerabilities/pipelines/v2_importers/gitlab_importer.pypreviously initializedVulnerabilitySeveritywithvalue=None. Because downstream package risk calculation (vulnerabilities/risk.py:48) requires a populated score (if not vul_score: continue), GitLab CVSS vectors were skipped, producing a0.0risk score for affected packages.Root Cause
The importer parsed vector strings into
scoring_elementswithout invoking the corresponding scoring system calculators.Implementation Summary
Following the precedent in
vulnerabilities/pipes/osv_v2.py:277-283:SCORING_SYSTEMS["cvssv2"].compute(cvss_v2_clean)."CVSS:3.1/"prefix to selectSCORING_SYSTEMS["cvssv3.1"]vs.SCORING_SYSTEMS["cvssv3"], computing the base score accordingly.(CVSS2MalformedError, CVSS3MalformedError), logging an error with the invalid vector while preserving the raw vector withvalue=""so the pipeline never halts on malformed upstream data.Tests Performed
test_parse_gitlab_advisory_computes_cvss_scores: Validated thatpypi.yamlvectors produce expected scores (5.0and7.5).test_parse_gitlab_advisory_cvss_v31_scoring_system: Validated CVSS 3.1 system dispatch and calculation (9.8).test_parse_gitlab_advisory_malformed_cvss_vectors: Validated that malformed vectors are logged as errors without crashing and retain empty string values.pytest vulnerabilities/tests/pipelines/v2_importers/test_gitlab_importer_v2.py(11 passed).blackandisort.Fixes #2330